import time

from xinan_ui.proxy.base_page import PageHandle
from xinan_ui.tools.App_driver import AppDriver01
from xinan_ui.tools.read_yml_xn import ReadYaml

data_eles = ReadYaml(r'D:\testLi\PythonWork\xinan_ui\config\jdzapp.yml').read_yaml()['Fir_page']


class EnterFirst(PageHandle):
    def __init__(self,driver):
        self.driver=driver
        super().__init__(self.driver)

    def enter_fir(self):
        #点击温馨提示弹窗
        self.click_button(data_eles[0]['温馨提示弹窗'])
        time.sleep(6)
        #点击交易风险提示确定按钮
        try:
            self.click_button(data_eles[3]['交易风险提示确定按钮'])
            time.sleep(2)
        except:
            print('没有出现点击交易风险提示')
        #温馨提示弹窗2
        try:
            self.click_button(data_eles[4]['温馨提示弹窗'])
            time.sleep(2)
        except:
            print('没有出现温馨提示弹窗')
        #点击交易按钮
        self.click_button(data_eles[1]['交易按钮'])
        time.sleep(3)
        #点击登录按钮
        self.click_button(data_eles[2]['点击登录按钮'])
        time.sleep(3)

if __name__ == '__main__':
    devices_data=ReadYaml(r'D:\testLi\PythonWork\xinan_ui\config\devices.yml').read_yaml()['yeshen_jdz']
    print(devices_data)
    driver=AppDriver01().get_driver(port=4723,desired_caps=devices_data)
    EnterFirst(driver).enter_fir()
